﻿var formCreatorController = function ($scope) {



    angular.element(document).ready(function () {

        //finding the form controls by name because the id is not used anymore
        var templateName                  = $('form').find('[name = templateName]');
        var selectTemplateDropDown = $('form').find('[name = selectTemplateDropDown]');
        var newQuestion                    = $('form').find('[name = newQuestion]');
        var selectQuestionDropDown = $('form').find('[name = selectQuestionDropDown]');
        var questionTypeLabel           = $('form').find('[name = questionTypeLabel]');
        var questionPlaceHolder        = $('form').find('[name = questionPlaceHolder]');
        var questionValues                 = $('form').find('[name = questionValues]');
        var questionOptions               = $('form').find('[name = questionOptions]');
        var addValues = $('form').find('button,input[value ="Add Values +"]');
       // addValues.addClass('btn btn-danger');
        var addOptions = $('form').find('button,input[type="button"] [value ="Add Options +"]');
    }); 


    $scope.FormModelData = {};
    $scope.FormDataModelTemplate = {
        "fieldset": {
            "type": "fieldset",
            "label": "Form Creator",           
            "fields": {
                "Template Name": {
                    "type": "text",
                    "label": "Template Name",
                    "model":"templateName",
                    "placeholder": "Template Name"
                },
                "or":  {
                    "type": "or",
                    "model": "orForTemplate",
                    "label": "or"
                },
                "TemplateDropDown":{
                    "type": "select",
                    "model": "selectTemplateDropDown",
                    "label": "select Template",
                    "empty": "nothing selected",
                    "options": {
                        "first": {
                            "label": "first Template"
                        },
                        "second": {
                            "label": "second Template",
                            "group": "first group"
                        },
                        "third": {
                            "label": "third Template",
                            "group": "second group"
                        },
                        "fourth": {
                            "label": "fourth Template",
                            "group": "first group"
                        },
                        "fifth": {
                            "label": "fifth Template"
                        },
                        "sixth": {
                            "label": "sixth Template",
                            "group": "second group"
                        },
                        "seventh": {
                            "label": "seventh Template"
                        },
                        "eighth": {
                            "label": "eighth Template",
                            "group": "first group"
                        },
                        "ninth": {
                            "label": "ninth Template",
                            "group": "second group"
                        },
                        "tenth": {
                            "label": "tenth option"
                        }
                    }
                },
                "NewQuestion": {
                    "type": "text",
                    "model": "newQuestion",
                    "label": "New Question",
                    "placeholder": "New Question"
                },
                "or For Question": {
                    "type": "or",
                    "model": "orForQuestion",
                    "label": "or"
                },
                "QuestionDropDown":{
                    "type": "select",
                    "model": "selectQuestionDropDown",
                    "label": "select Question",
                    "empty": "nothing selected",
                    "options": {
                        "first": {
                            "label": "first question"
                        },
                        "second": {
                            "label": "second question",
                            "group": "first group"
                        },
                        "third": {
                            "label": "third question",
                            "group": "second group"
                        },
                        "fourth": {
                            "label": "fourth question",
                            "group": "first group"
                        },
                        "fifth": {
                            "label": "fifth question"
                        },
                        "sixth": {
                            "label": "sixth question",
                            "group": "second group"
                        },
                        "seventh": {
                            "label": "seventh question"
                        },
                        "eighth": {
                            "label": "eighth question",
                            "group": "first group"
                        },
                        "ninth": {
                            "label": "ninth option",
                            "group": "second group"
                        },
                        "tenth": {
                            "label": "tenth option"
                        }
                }
            },
                "Input Type": {
                    "type": "select",
                    "model": "selectInputType",
                    "label": "select Question Type",
                    "empty": "nothing selected",
                    "options": {
                        "cero": {
                            "label": "label",
                            "group": "Text-based elements"
                        },
                        "one": {
                            "label": "text",
                            "group": "Text-based elements"
                        },
                        "two": {
                            "label": "textarea",
                            "group": "Text-based elements"
                        },
                        "three": {
                            "label": "date",
                            "group": "Text-based elements"
                        },
                        "four": {
                            "label": "datetime",
                            "group": "Text-based elements"
                        },
                        "five": {
                            "label": "email",
                            "group": "Text-based elements"
                        },
                        "sixth": {
                            "label": "month",
                            "group": "Text-based elements"
                        },
                        "seven": {
                            "label": "number",
                            "group": "Text-based elements"
                        },
                        "eighth": {
                            "label": "passwordn",
                            "group": "Text-based elements"
                        },
                        "nine": {
                            "label": "search",
                            "group": "Text-based elements"
                        },
                        "ten": {
                            "label": "tel",
                            "group": "Text-based elements"
                        },
                        "elleven": {
                            "label": "time",
                            "group": "Text-based elements"
                        },
                        "twelve": {
                            "label": "time",
                            "group": "Text-based elements"
                        },
                        "thirteen": {
                            "label": "url",
                            "group": "Text-based elements"
                        },
                        "fourteen": {
                            "label": "checkbox",
                            "group": "Specialized editables"
                        },
                        "fithteen": {
                            "label": "color",
                            "group": "Specialized editables"
                        },
                        "sixteen": {
                            "label": "file",
                            "group": "Specialized editables"
                        },
                        "seventeen": {
                            "label": "range",
                            "group": "Specialized editables"
                        },
                        "eighteen": {
                            "label": "select",
                            "group": "Specialized editables"
                        },
                        "nineteen": {
                            "label": "checklist",
                            "group": "Pseudo-non-editables (containers)"
                        },
                        "twenty": {
                            "label": "fieldset",
                            "group": "Pseudo-non-editables (containers)"
                        },
                        "twentyone": {
                            "label": "radio",
                            "group": "Pseudo-non-editables (containers)"
                        },
                        "twentythree": {
                            "label": "button",
                            "group": "Non-editables "
                        },
                        "twentyfour": {
                            "label": "hidden",
                            "group": "Non-editables "
                        },
                        "twentyfive": {
                            "label": "image",
                            "group": "Non-editables "
                        },
                        "twentysix": {
                            "label": "legend",
                            "group": "Non-editables "
                        },
                        "twentyseven": {
                            "label": "reset",
                            "group": "Non-editables "
                        },
                        "twentyeight": {
                            "label": "submit",
                            "group": "Non-editables "
                        }
                    }
                },
                    "Question Type Label": {
                        "type": "text",
                        "model": "questionTypeLabel",
                        "label": "Question Label",
                        "placeholder": "(Optional)"
                    },
                    "Question Type Placeholder": {
                        "type": "text",
                        "model": "questionPlaceHolder",
                        "label": "Question Place Holder",
                        "placeholder": "(Optional)"
                    },
                    "Question Values": {
                        "type": "text",
                        "model": "questionValues",
                        "label": "Question Values",
                        "placeholder": "Values seperated by comma (,)"
                    },
                    "Question Options": {
                        "type": "text",
                        "model": "questionOptions",
                        "label": "Question Options",
                        "placeholder": "Option Name"
                    },
                    "add Values Button": {
                        "type": "button",
                        "model": "addValues",
                        "label": "Add Values +"
                    } ,
                    "add Options Button": {
                        "type": "button",
                        "model": "addOptions",
                        "label": "Add Options +"
                    }, "checkList": {
                        "type": "checklist",
                        "model": "checklist",
                        "options": {
                            "first": {
                                "label": "first option"
                            },
                            "second": {
                                "label": "second option",
                            }
                        }
                    },
          
                }
           }
    };

};

